package com.nacos.consumer.controller;

import com.nacos.consumer.service.ConsumerService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;

@RestController
@RequestMapping("/consumer/call")
@RefreshScope
public class CallController {

    @Resource
    ConsumerService consumerService;

    @Resource
    RestTemplate restTemplate;


    @Value("${name}")
    private String name;

    @RequestMapping("/local")
    public String local() {
        return name;
    }


    @RequestMapping("/feign")
    public String feign() {
        return consumerService.get();
    }


    @RequestMapping("/ribbon")
    public String get() {
        return restTemplate.getForObject("http://nacos-provider/provider/config/get",String.class);
    }
}